
      PROGRAM  CHECK
C
C     PROGRAM MANAGES A CHECKING ACCOUNT
C       PREPARES REPORT FILES SORTED ON WHATEVER FIELD
C
C     USER NOTES:
C     THIS ROUTINE REQUIRES AN INPUT LEDGER FILE

      IMPLICIT REAL*4 (A-Z)
      REAL*4 AMOUNT,CHKSUM,SUMREC,NONREC,SUMDATE,SUMWITH,SUMDEP,SUMOTHER
      REAL*4 COUNT
      INTEGER MONTH,DAY,YEAR,CHECKNO,SORT,REC,DATESTART,DATEEND
      INTEGER MOSTR,DASTR,YRSTR,MOEND,DAEND,YREND,TODAY,CHKSTART,CHKEND
      CHARACTER*1 TYPE,TAXES,ANS,ANS1,ANS2,ANS3,RECONCILE
      CHARACTER*21 WHO
      CHARACTER*217 WHAT,WHATWORD
      CHARACTER*60 TITLE
      CHARACTER*40 FILIN, FILOUT

   10 FORMAT(A)
   30 WRITE(9,40)
   40 FORMAT(/,' input datafile: ')
      READ(9,'(A)') FILIN
      OPEN(UNIT=4,FILE=FILIN,STATUS='OLD',ERR=42)
      GOTO 48
   42 CONTINUE
      WRITE(9,44) FILIN
   44 FORMAT(/,' cannot find/open the specified file ',A,//)
      GOTO 30
   48 CONTINUE

C******************************** CHECK LEDGER ******************************
 
      WRITE(9,100)
  100 FORMAT(/,' Would you like to view the ledger file? Y/N',/)
      READ(9,10) ANS1
      IF(ANS1.EQ.'Y'.OR.ANS1.EQ.'y') THEN
        WRITE(9,300)
C  300 FORMAT(/,' Want an output file? Y/N',/)
        READ(9,10) ANS2
        IF(ANS2.EQ.'N'.OR.ANS2.EQ.'n') GOTO 108
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(9,50)
C   50 FORMAT('   output filename: ')
          READ(9,'(A)') FILOUT
          OPEN(UNIT=10,FILE=FILOUT,STATUS='NEW')
        ENDIF
  108 CONTINUE
        READ(4,10) TITLE
C  PRINT PROGRAM HEADER                                                 
        WRITE(9,90) TITLE, FILIN
   90 FORMAT(/,' CHECK PROGRAM',
     +/,' TITLE:  ',A,/,' LEDGER FILE: ',A,//,

     +'       date        chk   amount who                   what',/,
     +' -------------------------------------------------------------',
     +'--------')

        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,92) TITLE,FILIN
   92 FORMAT(/,T10,'CHECK PROGRAM',/,
     +T10,'TITLE: ',A,/,T10,'LEDGER FILE: ',A,//,
     +T10,'      date        chk   amount who                   what',/,
     +T10,'-----------------------------------------------------------',
     +'--------')
        DO 130 I=1,500
          READ(4,120,END=130,ERR=130) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
  120 FORMAT(A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,
     +1X,A21,1X,A17)

        IF(TYPE.EQ.'C') THEN
          WRITE(9,135) RECONCILE,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,
     +    AMOUNT,WHO,WHAT
  135 FORMAT(1X,A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,A,
     +1X,A17)
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,136) RECONCILE,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,
     +    AMOUNT,WHO,WHAT
  136 FORMAT(T10,A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,A,
     +1X,A17)
        ENDIF
          GOTO 130
        ENDIF
      WRITE(9,140) RECONCILE,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT
  140 FORMAT(1X,A1,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,23X,A17)
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
      WRITE(10,141) RECONCILE,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT
  141 FORMAT(T10,A1,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,23X,A17)
        ENDIF

  130 CONTINUE
      REWIND(4)
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,340) FILOUT
        CLOSE(10)
      ENDIF
      ENDIF

C****************************** CHECKBOOK **********************************
 
      WRITE(9,200)
  200 FORMAT(/,' Would you like to view the ledger file in checkbook',
     +' format? Y/N',/)
      READ(9,10) ANS1
      IF(ANS1.EQ.'Y'.OR.ANS1.EQ.'y') THEN
        WRITE(9,300)
C  300 FORMAT(/,' Want an output file? Y/N',/)
        READ(9,10) ANS2
        IF(ANS2.EQ.'N'.OR.ANS2.EQ.'n') GOTO 208
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(9,50)
C   50 FORMAT('   output filename: ')
          READ(9,'(A)') FILOUT
          OPEN(UNIT=10,FILE=FILOUT,STATUS='NEW')
        ENDIF
  208 CONTINUE
        READ(4,10) TITLE
        WRITE(9,203) TITLE, FILIN
  203 FORMAT(/,T25,'CHECKBOOK PROGRAM',//,
     +' TITLE:  ',A,/,' DATA FILE: ',A,//,
     +'       date      chk   amount who                      balance',/,
     +' -------------------------------------------------------------')
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,204) TITLE,FILIN
  204 FORMAT(/,T10,'CHECKBOOK PROGRAM',/,
     +T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'      date      chk   amount who                    ',
     +'  balance',/,
     +T10,'-----------------------------------------------------------',
     +'--')
        CHKSUM=0.00
        DO 230 I=1,500
          READ(4,120,ERR=230,END=230) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
          IF(TYPE.EQ.'D'.OR.TYPE.EQ.'d') TYPE='D'
          IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') TYPE='W'
          IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') TYPE='C'
          IF(TYPE.EQ.'O'.OR.TYPE.EQ.'o') TYPE='O'
          IF(TYPE.EQ.'D') CHKSUM=CHKSUM+AMOUNT
          IF(TYPE.EQ.'W') CHKSUM=CHKSUM-AMOUNT
          IF(TYPE.EQ.'C') CHKSUM=CHKSUM-AMOUNT
          IF(TYPE.EQ.'O') CHKSUM=CHKSUM-AMOUNT

C     INTEREST IS HANDLED AS A DEPOSIT

          IF(TYPE.EQ.'C') THEN
            WRITE(9,235) RECONCILE,MONTH,DAY,YEAR,TYPE,CHECKNO,
     +      AMOUNT,WHO,CHKSUM
  235 FORMAT(1X,A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,I4,1X,F8.2,1X,A21,
     +1X,F10.2)
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,236) RECONCILE,MONTH,DAY,YEAR,TYPE,CHECKNO,
     +      AMOUNT,WHO,CHKSUM
  236 FORMAT(T10,A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,I4,1X,F8.2,1X,A21,
     +1X,F10.2)
        ENDIF
        GOTO 220
        ENDIF
      WRITE(9,237) RECONCILE,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,CHKSUM
  237 FORMAT(1X,A1,1X,I2,1X,I2,1X,I4,1X,A1,6X,F8.2,1X,A17,5X,F10.2)
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(10,238) RECONCILE,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,CHKSUM
  238 FORMAT(T10,A1,1X,I2,1X,I2,1X,I4,1X,A1,6X,F8.2,1X,A17,5X,F10.2)
        ENDIF
  220 CONTINUE
  230 CONTINUE
        REWIND(4)
        WRITE(9,240) CHKSUM
  240 FORMAT(/,' does this look familiar? is the balance ',F10.2,'?',/)
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,340) FILOUT
        CLOSE(10)
      ENDIF
      ENDIF

C******************* SORTED OUTPUT ****************************************

  305 CONTINUE
      WRITE(9,306)
  306 FORMAT(/,' Want to see a sorted file? Y/N',/)
      READ(9,10) ANS3
      IF(ANS3.EQ.'N'.OR.ANS3.EQ.'n') GOTO 2000
C      IF(ANS3.EQ.'Y'.OR.ANS3.EQ.'y') THEN

        WRITE(9,300)
  300 FORMAT(/,' Want an output file? Y/N',/)
        READ(9,10) ANS2
        IF(ANS2.EQ.'N'.OR.ANS2.EQ.'n') GOTO 308
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(9,50)
   50 FORMAT('   output filename: ')
          READ(9,'(A)') FILOUT
          OPEN(UNIT=10,FILE=FILOUT,STATUS='NEW')
        ENDIF
  308 CONTINUE
        WRITE(9,310)
  310 FORMAT(/,' what would you like to sort on..choose one:',/,
     +         '    choice  positive sort field',/,
     +         '    ---------------------------------------',/,
     +         '       1    reconciled entries',/,
     +         '       2    all non reconciled entries',/,
     +         '       3    all transactions - by date range',/,
     +         '       4    non reconciled checks',/,
     +         '       5    non reconciled deposits',/,
     +         '       6    deposits - by date range',/,
     +         '       7    withdrawals - by data range',/,
     +         '       8    other debits - by date range',/,
     +         '       9    checks - by range of check numbers',/,
     +         '      10    all debits - by date range',/,
     +         '      11    explanation keywords',/,
     +         '      12    possible tax expense implications',/,
     +         '      13    quit',//)
  
      READ(9,*) SORT
      IF(SORT.EQ.1) GOTO 312
      IF(SORT.EQ.2) GOTO 400
      IF(SORT.EQ.3) GOTO 502
      IF(SORT.EQ.4) GOTO 600
      IF(SORT.EQ.5) GOTO 650
      IF(SORT.EQ.6) GOTO 752
      IF(SORT.EQ.7) GOTO 702
      IF(SORT.EQ.8) GOTO 802
      IF(SORT.EQ.9) GOTO 900
      IF(SORT.EQ.10) GOTO 950
      IF(SORT.EQ.11) GOTO 1000
      IF(SORT.EQ.12) GOTO 1200
      IF(SORT.GT.13) GOTO 305
      IF(SORT.EQ.13) GOTO 2000

C******************************* SORT 1 RECONCILED ************************

  312 CONTINUE
      READ(4,10) TITLE
      WRITE(9,314) TITLE, FILIN
  314 FORMAT(/,' PROGRAM CHECK - SUMMARY OF RECONCILED TRANSACTIONS',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'          date        chk   amount who/what               ',
     +'  balance',/,
     +' ----------------------------------------------------------',
     +'--------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,315) TITLE, FILIN
  315 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF RECONCILED TRANSACTIONS',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date        chk   amount who/what               ',
     +'  balance',/,
     +T10,'---------------------------------------------------------',
     +'---------')
      SUMREC=0.00
      COUNT=0
      DO 320 I=1,500
        REC=0
        RECONCILE=' '
        READ(4,120,END=320,ERR=320) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'D'.OR.TYPE.EQ.'d') TYPE='D'
        IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') TYPE='W'
        IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') TYPE='C'
        IF(TYPE.EQ.'O'.OR.TYPE.EQ.'o') TYPE='O'
        IF(RECONCILE.EQ.'Y'.OR.RECONCILE.EQ.'y') REC=2
        IF(REC.EQ.2) THEN
          IF(TYPE.EQ.'D') SUMREC=SUMREC+AMOUNT
          IF(TYPE.EQ.'W') SUMREC=SUMREC-AMOUNT
          IF(TYPE.EQ.'C') SUMREC=SUMREC-AMOUNT
          IF(TYPE.EQ.'O') SUMREC=SUMREC-AMOUNT
          COUNT=COUNT+1
          IF(TYPE.EQ.'C') THEN
            WRITE(9,409)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,SUMREC
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,416)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,SUMREC
          ENDIF
          GOTO 337
          ENDIF
        WRITE(9,417) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMREC
            IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
              WRITE(10,418) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMREC
            ENDIF
  337 CONTINUE
        ENDIF
  320 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,340) FILOUT
  340 FORMAT(/,' your reconciled sort output is in file ',A)
        CLOSE(10)
      ENDIF
        REWIND(4)
      GOTO 305

C********************** SORT 2 NON-RECONCILED ******************************

  400 CONTINUE
      READ(4,10) TITLE
      WRITE(9,414) TITLE, FILIN
  414 FORMAT(/,' PROGRAM CHECK - SUMMARY OF NON-RECONCILED ',
     +'TRANSACTIONS',/,
     +' TITLE:  ',A,/,' DATA FILE: ',A,//,

     +'          date        chk   amount who/what               ',
     +'  balance',/,
     +' ---------------------------------------------------------',
     +'---------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,415) TITLE, FILIN
  415 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF NON-RECONCILED',
     +' TRANSACTIONS',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date        chk   amount who/what               ',
     +'  balance',/,
     +T10,'---------------------------------------------------------',
     +'---------')
      NONREC=0.00
      COUNT=0.
      DO 420 I=1,500
      REC=0
        READ(4,120,ERR=420,END=420) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(RECONCILE.EQ.' '.OR.RECONCILE.EQ.'N') REC=1
        IF(REC.EQ.1) THEN
          IF(TYPE.EQ.'D'.OR.TYPE.EQ.'d') TYPE='D'
          IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') TYPE='W'
          IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') TYPE='C'
          IF(TYPE.EQ.'O'.OR.TYPE.EQ.'o') TYPE='O'
          IF(TYPE.EQ.'D') NONREC=NONREC+AMOUNT
          IF(TYPE.EQ.'W') NONREC=NONREC-AMOUNT
          IF(TYPE.EQ.'C') NONREC=NONREC-AMOUNT
          IF(TYPE.EQ.'O') NONREC=NONREC-AMOUNT
          COUNT=COUNT+1.
        IF(TYPE.EQ.'C') THEN
          WRITE(9,409)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,NONREC
  409 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,
     +A21,1X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,416)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,NONREC
  416 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,
     +A21,1X,F10.2)
          ENDIF
          GOTO 425
        ENDIF
       WRITE(9,417) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,NONREC
  417 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,1X,A17,5X,F10.2)

            IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
              WRITE(10,418) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,NONREC
  418 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,1X,A17,5X,F10.2)
            ENDIF
        ENDIF
  425 CONTINUE
  420 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,440) FILOUT
  440 FORMAT(/,' your non-reconciled sort output is in file ',A)
        CLOSE(10)
      ENDIF
        REWIND(4)
      GOTO 305

C************** SORT 3 DATE - NON RECONCILED BY DATE *********************

  502 CONTINUE
      WRITE(9,500)
  500 FORMAT(/,' input start month, day, year as MMDDYYYY')
      READ(9,503) MOSTR,DASTR,YRSTR
  503 FORMAT(I2,I2,I4)
      DATESTART = YRSTR*10000 + MOSTR*100 + DASTR

C DIAGNOSTICS - GOOD STUFF FOR DEBUGGING INPUT
C      WRITE(9,1000) DASTR,MOSTR,YRSTR,DATESTART
C      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
C        WRITE(10,1000) DASTR,MOSTR,YRSTR,DATESTART
C 1000 FORMAT(//,' DASTR = ',I2,' MOSTR = ',I2,'  YRSTR = ',I4,/,
C     +' DATESTART = ',I8,//)
C      ENDIF

      WRITE(9,505)
  505 FORMAT(/,' input end month, day, year as MMDDYYYY')
      READ(9,503) MOEND,DAEND,YREND
      DATEEND = YREND*10000 + MOEND*100 + DAEND

C      WRITE(9,1002) DAEND,MOEND,YREND,DATEEND,DATEEND-DATESTART
C      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
C        WRITE(10,1002) DAEND,MOEND,YREND,DATEEND,DATEEND-DATESTART
C 1002 FORMAT(//,' DAEND = ',I2,' MOEND = ',I2,'  YREND = ',I4,/,
C     +' DATEEND = ',I8,'  DATESTART - DATEEND = ',I8,//)
C      ENDIF

      READ(4,10) TITLE
      WRITE(9,514) TITLE, FILIN
  514 FORMAT(/,' PROGRAM CHECK - SUMMARY OF TRANSACTIONS BETWEEN',
     +' SELECTED DATES',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'          date        chk   amount who/what               ',
     +'  balance',/,
     +' ----------------------------------------------------------',
     +'--------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,515) TITLE, FILIN
  515 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF TRANSACTIONS BETWEEN',
     +' SELECTED DATES',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date        chk   amount who/what               ',
     +'  balance',/,
     +T10,'----------------------------------------------------------',
     +'--------')
      SUMDATE=0.00
      DO 520 I=1,500
        REC=0
        READ(4,120,ERR=520,END=520) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
C        IF(RECONCILE.EQ.'Y'.OR.RECONCILE.EQ.'y') REC=2
C        IF(REC.EQ.2) THEN
        TODAY=YEAR*10000+MONTH*100+DAY
C
C      WRITE(10,1004) TODAY
C 1004 FORMAT(//,' TODAY = ',I8,//)
C
        IF(TODAY.GE.DATESTART.AND.TODAY.LE.DATEEND) THEN
          IF(TYPE.EQ.'D') SUMDATE=SUMDATE+AMOUNT
          IF(TYPE.EQ.'W') SUMDATE=SUMDATE-AMOUNT
          IF(TYPE.EQ.'C') SUMDATE=SUMDATE-AMOUNT
          IF(TYPE.EQ.'O') SUMDATE=SUMDATE-AMOUNT
        COUNT=I
        IF(TYPE.EQ.'C') THEN
          WRITE(9,331)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,SUMDATE
  331 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,
     +A21,1X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,333)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,SUMDATE
  333 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,
     +A21,1X,F10.2)
          ENDIF
          GOTO 525
        ENDIF
        WRITE(9,339) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMDATE
  339 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,1X,A17,5X,F10.2)
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,338) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMDATE
  338 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,1X,A17,5X,F10.2)
          ENDIF
        ENDIF
C        ENDIF
  525 CONTINUE
  520 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,540) FILOUT
  540 FORMAT(/,' your date sort output is in file ',A)
        CLOSE(10)
      ENDIF
      REWIND(4)
      GOTO 305

C********************** SORT 4 NON-RECONCILED CHECKS ********************

  600 CONTINUE
      READ(4,10) TITLE
      WRITE(9,614) TITLE, FILIN
  614 FORMAT(/,' PROGRAM CHECK - SUMMARY OF NON-RECONCILED CHECKS',
     +/,' TITLE:  ',A,/,' DATA FILE: ',A,//,
     +'          date        chk   amount who                    ',
     +'  balance',/,
     +' ---------------------------------------------------------',
     +'----------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,615) TITLE, FILIN
  615 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF NON-RECONCILED',
     +' CHECKS',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date        chk   amount who                    ',
     +'  balance',/,
     +T10,'---------------------------------------------------------',
     +'---------')
      NONREC=0.00
      COUNT=0.
      DO 620 I=1,500
        REC=0
        READ(4,120,ERR=620,END=620) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT

        IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') TYPE='C'
        IF(RECONCILE.EQ.' '.OR.RECONCILE.EQ.'N') REC=1
        IF(REC.EQ.1.AND.TYPE.EQ.'C') THEN
          NONREC=NONREC+AMOUNT
          COUNT=COUNT+1.
          WRITE(9,609)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,NONREC
  609 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,
     +A21,1X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,616)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,NONREC
  616 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,1X,
     +A21,1X,F10.2)
          ENDIF
        ENDIF
  620 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,640) FILOUT
  640 FORMAT(/,' your non-reconciled check sort is in file ',A)
        CLOSE(10)
      ENDIF
        REWIND(4)
      GOTO 305

C********************** SORT 5 NON-RECONCILED DEPOSITS ********************

  650 CONTINUE
      READ(4,10) TITLE
      WRITE(9,654) TITLE, FILIN
  654 FORMAT(/,' PROGRAM CHECK - SUMMARY OF NON-RECONCILED DEPOSITS',
     +/,' TITLE:  ',A,/,' DATA FILE: ',A,//,
     +'          date              amount         total',/,
     +' -----------------------------------------------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,655) TITLE, FILIN
  655 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF NON-RECONCILED',
     +' DEPOSITS',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date              amount         total',/,
     +T10,'-----------------------------------------------')
      NONREC=0.00
      COUNT=0.
      DO 660 I=1,500
        REC=0
        READ(4,120,ERR=660,END=660) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'D'.OR.TYPE.EQ.'d') TYPE='D'
        IF(RECONCILE.EQ.' '.OR.RECONCILE.EQ.'N') REC=1
        IF(REC.EQ.1.AND.TYPE.EQ.'D') THEN
          NONREC=NONREC+AMOUNT
          COUNT=COUNT+1.
          WRITE(9,659)COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,NONREC
  659 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,4X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,658)COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,NONREC
  658 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,4X,F10.2)
          ENDIF
        ENDIF
  660 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,640) FILOUT
C  640 FORMAT(/,' your non-reconciled deposit sort is in file ',A)
        CLOSE(10)
      ENDIF
        REWIND(4)
      GOTO 305

C******************* SORT 6 DEPOSITS BY DATE RANGE *************************

  752 CONTINUE
      WRITE(9,500)
      READ(9,503) MOSTR,DASTR,YRSTR
      DATESTART = YRSTR*10000 + MOSTR*100 + DASTR
      WRITE(9,505)
      READ(9,503) MOEND,DAEND,YREND
      DATEEND = YREND*10000 + MOEND*100 + DAEND
      READ(4,10) TITLE
      WRITE(9,750) TITLE, FILIN
  750 FORMAT(/,' PROGRAM CHECK - SUMMARY OF DEPOSITS BETWEEN',
     +' SELECTED DATES',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'          date              amount         total',/,
     +' -----------------------------------------------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,755) TITLE, FILIN
  755 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF DEPOSITS BETWEEN',
     +' SELECTED DATES',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date              amount         total',/,
     +T10,'-----------------------------------------------')
      SUMDEP=0.00
      COUNT=0
      DO 780 I=1,500
        REC=0
        READ(4,120,ERR=780,END=780) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'D'.OR.TYPE.EQ.'d') REC=3
        IF(REC.EQ.0) GOTO 777
        TODAY=YEAR*10000+MONTH*100+DAY
        IF(TODAY.GE.DATESTART.AND.TODAY.LE.DATEEND) THEN
          IF(TYPE.EQ.'D') SUMDEP=SUMDEP+AMOUNT
          COUNT=COUNT+1
          WRITE(9,759) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,SUMDEP
  759 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,4X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,758) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,SUMDEP
  758 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,4X,F10.2)
          ENDIF
        ENDIF
  777 CONTINUE
  780 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,640) FILOUT
        CLOSE(10)
      ENDIF
      REWIND(4)
      GOTO 305

C******************* SORT 7 WITHDRAWALS BY DATE RANGE *************************

  702 CONTINUE
      WRITE(9,500)
      READ(9,503) MOSTR,DASTR,YRSTR
      DATESTART = YRSTR*10000 + MOSTR*100 + DASTR
      WRITE(9,505)
      READ(9,503) MOEND,DAEND,YREND
      DATEEND = YREND*10000 + MOEND*100 + DAEND
      READ(4,10) TITLE
      WRITE(9,700) TITLE, FILIN
  700 FORMAT(/,' PROGRAM CHECK - SUMMARY OF WITHDRAWALS BETWEEN',
     +' SELECTED DATES',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'          date              amount         total',/,
     +' -----------------------------------------------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,705) TITLE, FILIN
  705 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF WITHDRAWALS BETWEEN',
     +' SELECTED DATES',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date              amount         total',/,
     +T10,'-----------------------------------------------')
      SUMWITH=0.00
      COUNT=0
      DO 738 I=1,500
        REC=0
        READ(4,120,ERR=738,END=738) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') REC=3
        IF(REC.EQ.0) GOTO 737
        TODAY=YEAR*10000+MONTH*100+DAY
        IF(TODAY.GE.DATESTART.AND.TODAY.LE.DATEEND) THEN
          IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') SUMWITH=SUMWITH+AMOUNT
          COUNT=COUNT+1
          WRITE(9,719) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,SUMWITH
  719 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,4X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,718) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,SUMWITH
  718 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,4X,F10.2)
          ENDIF
        ENDIF
  737 CONTINUE
  738 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,640) FILOUT
        CLOSE(10)
      ENDIF
      REWIND(4)
      GOTO 305

C******************** SORT 8 OTHER DEBITS BY DATE RANGE **********************

  802 CONTINUE
      WRITE(9,500)
      READ(9,503) MOSTR,DASTR,YRSTR
      DATESTART = YRSTR*10000 + MOSTR*100 + DASTR
      WRITE(9,505)
      READ(9,503) MOEND,DAEND,YREND
      DATEEND = YREND*10000 + MOEND*100 + DAEND
      READ(4,10) TITLE
      WRITE(9,814) TITLE, FILIN
  814 FORMAT(/,' PROGRAM CHECK - SUMMARY OF OTHER DEBITS BETWEEN',
     +' SELECTED DATES',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'          date              amount who/what               ',
     +'   total',/,
     +' ----------------------------------------------------------',
     +'--------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,815) TITLE, FILIN
  815 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF OTHER DEBITS BETWEEN',
     +' SELECTED DATES',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date              amount who/what               ',
     +'    total',/,
     +T10,'----------------------------------------------------------',
     +'--------')
      SUMOTHER=0.00
      COUNT=0
      DO 820 I=1,500
        REC=0
        READ(4,120,ERR=820,END=820) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'O'.OR.TYPE.EQ.'o') REC=3
        IF(REC.EQ.0) GOTO 817
        TODAY=YEAR*10000+MONTH*100+DAY
        IF(TODAY.GE.DATESTART.AND.TODAY.LE.DATEEND) THEN
          IF(TYPE.EQ.'O') SUMOTHER=SUMOTHER+AMOUNT
          COUNT=COUNT+1
          WRITE(9,839) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMOTHER
  839 FORMAT(1X,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,1X,A17,5X,F10.2)
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,838) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMOTHER
  838 FORMAT(T10,F4.0,1X,I2,1X,I2,1X,I4,1X,A1,8X,F8.2,1X,A17,5X,F10.2)
          ENDIF
        ENDIF
  817 CONTINUE
  820 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,640) FILOUT
        CLOSE(10)
      ENDIF
      REWIND(4)
      GOTO 305

C**************** SORT 9 CHECKS BY RANGE OF CHECK NUMBERS *******************

  900 CONTINUE
        WRITE(9,917)
  917 FORMAT(/,' start check number: ',/)
        READ(9,907) CHKSTART
  907 FORMAT(I4)
        WRITE(9,918)
  918 FORMAT(/,' ending check number: ',/)
        READ(9,907) CHKEND
      READ(4,10) TITLE
      WRITE(9,905) TITLE, FILIN
  905 FORMAT(/,' PROGRAM CHECK - SUMMARY OF CHECKS BY NUMBER',
     +/,' TITLE:  ',A,/,' DATA FILE: ',A,//,
     +'          date        chk   amount who                    ',
     +'    total',/,
     +' ---------------------------------------------------------',
     +'---------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,915) TITLE, FILIN
  915 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF CHECKS BY NUMBER',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date        chk   amount who                    ',
     +'    total',/,
     +T10,'---------------------------------------------------------',
     +'---------')
      CHKSUM=0.00
      COUNT=0.
      DO 920 I=1,500
        READ(4,120,ERR=920,END=920) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') TYPE='C'
          IF(TYPE.EQ.'C') THEN
          IF(CHECKNO.GE.CHKSTART.AND.CHECKNO.LE.CHKEND) THEN
            CHKSUM=CHKSUM+AMOUNT
            COUNT=COUNT+1.
            WRITE(9,609)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,CHKSUM
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,616)COUNT,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,AMOUNT,
     +WHO,CHKSUM
            ENDIF
          ENDIF
        ENDIF
  920 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,930) FILOUT
  930 FORMAT(/,' your check number sort is in output file ',A,/)
        CLOSE(10)
      ENDIF
        REWIND(4)
      GOTO 305

C******************** SORT 10 ALL DEBITS BY DATE RANGE **********************

  950 CONTINUE
      WRITE(9,500)
      READ(9,503) MOSTR,DASTR,YRSTR
      DATESTART = YRSTR*10000 + MOSTR*100 + DASTR
      WRITE(9,505)
      READ(9,503) MOEND,DAEND,YREND
      DATEEND = YREND*10000 + MOEND*100 + DAEND
      READ(4,10) TITLE
      WRITE(9,954) TITLE, FILIN
  954 FORMAT(/,' PROGRAM CHECK - SUMMARY OF ALL DEBITS BETWEEN',
     +' SELECTED DATES',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'          date              amount who/what               ',
     +'   total',/,
     +' ----------------------------------------------------------',
     +'--------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,955) TITLE, FILIN
  955 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF ALL DEBITS BETWEEN',
     +' SELECTED DATES',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'         date              amount who/what               ',
     +'    total',/,
     +T10,'----------------------------------------------------------',
     +'--------')
      SUMOTHER=0.00
      COUNT=0
      DO 970 I=1,500
        REC=0
        READ(4,120,ERR=970,END=970) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') REC=3
        IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') REC=3
        IF(TYPE.EQ.'O'.OR.TYPE.EQ.'o') REC=3
        IF(REC.EQ.0) GOTO 967
        TODAY=YEAR*10000+MONTH*100+DAY
        IF(TODAY.GE.DATESTART.AND.TODAY.LE.DATEEND) THEN
          SUMOTHER=SUMOTHER+AMOUNT
          COUNT=COUNT+1
          WRITE(9,839) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMOTHER
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,838) COUNT,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT,SUMOTHER
          ENDIF
        ENDIF
  967 CONTINUE
  970 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,980) FILOUT
  980 FORMAT(/,' your date sorted debit file is ',A,/)
        CLOSE(10)
      ENDIF
      REWIND(4)
      GOTO 305

C********************** SORT 11 WHO/WHAT KEYWORD SORT   ******************

 1000 CONTINUE
      WRITE(9,1010)
 1010 FORMAT(/,' what string do you want to sort on?',//,
     +' you may use up to 17 characters, which must be the same',/,
     +' group of characters as used in the ledger file, including',/,
     +' case sensitivity. The string that you enter is left justified',/,
     +' which means that trailing blanks are added to fill out the 17',/,
     +' available spaces. Therefore, if the ledger file is "medicine"',/,
     +' then a keyword search using "med" or "medicine - heart" will',/,
     +' fail.',//)
      READ(9,10) WHATWORD
      READ(4,10) TITLE
      IF(ANS3.EQ.'Y'.OR.ANS3.EQ.'y') GOTO 1070
      WRITE(9,90) TITLE, FILIN
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,92) TITLE, FILIN
 1070 CONTINUE
      COUNT=0
      DO 1030 I=1,500
        READ(4,120,END=1030,ERR=1030) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(WHAT.EQ.WHATWORD.OR.WHO.EQ.WHATWORD) THEN
          WRITE(9,1050) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
          IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
            WRITE(10,1055) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
          ENDIF
 1050 FORMAT(1X,A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,
     +1X,A21,1X,A17)
 1055 FORMAT(T10,A1,1X,I2,1X,I2,1X,I4,1X,A1,1X,A1,1X,I4,1X,F8.2,
     +1X,A21,1X,A17)
         ENDIF
 1030 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,1075)
 1075 FORMAT(/)
      REWIND(4)
      WRITE(9,1060)
 1060 FORMAT(/,' would you like another sort? Y/N ',/)
      READ(9,10) ANS3
      IF(ANS3.EQ.'Y'.OR.ANS3.EQ.'y') GOTO 1000
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,1040) FILOUT
 1040 FORMAT(/,' your who/what sort output is in file ',A)
        CLOSE(10)
      ENDIF
      GOTO 305

C************************** SORT 12 TAX TRANSACTIONS ************************

 1200 CONTINUE
      READ(4,10) TITLE
      WRITE(9,1210) TITLE, FILIN
 1210 FORMAT(/,' PROGRAM CHECK - SUMMARY OF TAX TRANSACTIONS',
     +/,' TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +'       date        chk   amount who                   what',/,
     +' -------------------------------------------------------------',
     +'--------')
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') WRITE(10,1215) TITLE, FILIN
 1215 FORMAT(/,T10,'PROGRAM CHECK - SUMMARY OF RECONCILED TRANSACTIONS',
     +/,T10,'TITLE:  ',A,/,T10,'DATA FILE: ',A,//,
     +T10,'       date        chk   amount who                   what',/,
     +T10,' -----------------------------------------------------------',
     +'----------')
      DO 1230 I=1,500
        READ(4,120,END=1230,ERR=1230) RECONCILE,MONTH,DAY,YEAR,TYPE,
     +TAXES,CHECKNO,AMOUNT,WHO,WHAT
        IF(TYPE.EQ.'D'.OR.TYPE.EQ.'d') TYPE='D'
        IF(TYPE.EQ.'W'.OR.TYPE.EQ.'w') TYPE='W'
        IF(TYPE.EQ.'C'.OR.TYPE.EQ.'c') TYPE='C'
        IF(TYPE.EQ.'O'.OR.TYPE.EQ.'o') TYPE='O'
      IF(TAXES.EQ.'Y'.OR.TAXES.EQ.'y') THEN
        IF(TYPE.EQ.'C') THEN
          WRITE(9,135) RECONCILE,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,
     +    AMOUNT,WHO,WHAT
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,136) RECONCILE,MONTH,DAY,YEAR,TYPE,TAXES,CHECKNO,
     +    AMOUNT,WHO,WHAT
        ENDIF
          GOTO 1235
        ENDIF
        WRITE(9,140) RECONCILE,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT
        IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
          WRITE(10,141) RECONCILE,MONTH,DAY,YEAR,TYPE,AMOUNT,WHAT
        ENDIF
 1235 CONTINUE
      ENDIF
 1230 CONTINUE
      IF(ANS2.EQ.'Y'.OR.ANS2.EQ.'y') THEN
        WRITE(9,1240) FILOUT
 1240 FORMAT(/,' your tax sort output is in file ',A)
        CLOSE(10)
      ENDIF
        REWIND(4)
      GOTO 305

C****************************************************************************


 2000 CONTINUE
C      WRITE(9,2010) FILOUT
C 2010 FORMAT(//,' thats it for now...',//)
C      CLOSE(UNIT=4)
C      WRITE(9,2020)
C 2020 FORMAT(/,' the input file is closed...',/)
      STOP
      END
